<?php
require '../database/sales.php';
$sale=new sales();
$recordnumber=$sale->getRecordNumber();
//echo $recordnumber;
if(!isset($_GET['trang']))$_GET['trang']=1;
$vitri=($_GET['trang']-1)*10;
$array=$sale->page($vitri);
?>

<style>
    #sale{
        height: 699px;
        border-bottom: 1px solid #0099FF;
    }
    #page{
        height: 60px;
    }
</style>
<script type="text/javascript">
        $(document).ready(function(){
            $("a.del").click(function(){
               if(confirm("Bạn có muốn xóa không ?")){
                  $id=$(this).attr("name"); 
                  $(this).parent().parent().fadeOut("slow");                 
                  $.ajax({
                      "url": "modules/sales/deleteajax.php",                     
                      "type":"post",
                      "data":"uid="+$id,
                      "async":"false",
                      success: function (data) {                     
                    }
                  });
               } 
               return false;
              
            });
        });
        </script>
<div id="sale">
    <h1>Danh sach cac mat hang khuyen mai</h1>
    <table border="1px">
        <tr>
            <td>Mã</td>
            <td>Tên sản phẩm-Số lô</td>
            <td>Số lượng sản phẩm khuyến mãi</td>
            <td>Tỷ lệ khuyến mãi(%)</td>
            <td>Gía khuyến mãi(vnd)</td>
            <td>Thời gian bắt đầu</td>
            <td>Thời gian kết thúc</td>
            <td>Ghi chú</td>
        </tr>
        <?php foreach ($array as $data) {?>
        <tr>
            <td><?php echo $data['sales_Id'];?></td>
            <td><?php echo $data['pro_Id'];?></td>
            <td><?php echo $data['sales_number'];?></td>
            <td><?php echo $data['sales_sales'];?></td>
            <td><?php echo $data['priceSales'];?></td>
            <td><?php echo $data['start'];?></td>
            <td><?php echo $data['end'];?></td>
            <td><?php echo $data['notice'];?></td>
            <td> 
            <a href="#">
                <img src="images/detail.png" width="15" height="15" title="Chi tiet"></a>
            <a href="javascript:void(0)" class="del" name="<?php echo $data['sales_Id'];?>">
                <img src="images/delete.png" width="15" height="15"title="Xoa"></a>
            <a href='<?php echo baseurl."admin/index.php?page=sales&act=edit&id=".$data['sales_Id'];?>'>
                <img src="images/update.png"width="15" height="15" title="Cap nhat"></a>
            </td>    
        </tr>
      <?php   } ?>
    </table>
</div>
<div id="page">
      <?php $tongsotrang= ceil($recordnumber/10);
    for($i=1;$i<=$tongsotrang;$i++)
        echo "<a href='index.php?page=sales&act=list&trang=$i'>$i</a>";
    ?>
</div>